package tech.hypersense.shared.hsauth.handler;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.web.access.AccessDeniedHandler;
import tech.hypersense.common.core.enums.ResultCode;
import tech.hypersense.common.core.utils.ResponseUtils;

/**
 * @Author: HyperSense
 * @CreateTime: 2025-03-26
 * @Description: 无权限访问处理器
 * @Version: 1.0
 */
public class MyAccessDeniedHandler implements AccessDeniedHandler {

    @Override
    public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException accessDeniedException) {
        ResponseUtils.writeErrMsg(response, ResultCode.ACCESS_UNAUTHORIZED);
    }

}
